﻿using d1Common.WebController;
using d1Project.Modules.Business.doXZ.Models;
using d1Project.Tools;
using d1Project.Tools.PagedList;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;

namespace d1Project.Modules.Business.doXZ.Controllers.a1
{
    [Route("a1/XZ_a1_Gswh_put")]
    public class XZ_a1_Gswh_putController : ControllerBase
    {
        protected override DbContext dbContext
        {
            get
            {
                return this.db;
            }
        }
        private doXZDbContext db = new doXZDbContext();

        /// <summary>
        /// 公式常数编辑
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<IHttpActionResult> Post(XZ_GswhModelPostVm model)
        {
            if (!ModelState.IsValid) this.Error("请求参数不正确");
            //XZ_GswhModel entity = new XZ_GswhModel();
            var entity = await db.XZ_Gswh.FindAsync(model.Id);
            entity.Name = model.Name;
            entity.Num = model.Num;
            await db.SaveChangesAsync();
            return Ok(new { name = 1 });
        }
        public class XZ_GswhModelPostVm
        {
            /// <summary>
            /// 编号
            /// </summary>
            public int Id { get; set; }
            public string Name { get; set; }
            public double Num { get; set; }
        }
    }
}
